<?php 
session_start();

require("../../conexao/ConectaMysql.class.php");
require("../../conexao/ControleAcesso.class.php");

require("setor.class.php");
require("gerencia_setor.class.php");

ControleAcesso::verificaSessao();
$conexao = new ConectaMysql();


if (isset($_POST['Cadastrar'])){
	
	$gerenciaSetor = new GerenciaSetor($conexao);
	
	$SETnome 	= $_POST['SETnome'];
	$SETsigla 	= $_POST['SETsigla'];
	
	$result_setor = $gerenciaSetor->selectMaxId();
	foreach($result_setor  as $row_setor){  
		$SETid = $row_setor['SETid'] + 1;
	}
	
	$setor = new setor($SETid, $SETnome, $SETsigla);	
	
	$gerenciaSetor->insertSetor($setor);

}else{

?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Setor</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="../../estrutura/css/estruturaCadastro.css" rel="stylesheet" type="text/css" media="screen" />
<script type="text/javascript" src="../../estrutura/js/jquery.js"></script>
<script type="text/javascript" src="../../estrutura/js/jquery.validate.js"></script>
<script type="text/javascript" src="../../estrutura/js/validacaoSetor.js"></script>
</head>

<body>
<div align="left">
    <form action="inserir_setor.php" method="post" name="formSetor" id="formSetor" target="_self">
        <table width="90%"  border="0" align="center">
            <tr>
            	<td colspan="2" bgcolor="#DFEDF7" class="texto"><div align="left"></div><strong>Informe os dados do Setor</strong></td>
            </tr>
            <tr>
            	<td colspan="2" class="texto"><span class="style50">* campos obrigat&oacute;rios</span></td>
            </tr>
            <tr>
                <td width="21%" bgcolor="#FFFFFF" class="texto">&nbsp;</td>
                <td width="79%">&nbsp;</td>
            </tr>
            <tr>
                <td bgcolor="#F1F4F8" class="texto">Nome do Setor: </td>
                <td>
                    <span class="style50">
                    <label>
                        <input type="text" name="SETnome" id="SETnome">
                    </label>
                    *</span>
                </td>
            </tr>
            <tr>
                <td bgcolor="#F1F4F8" class="texto style41"><span class="texto">Sigla do Setor:</span></td>
                <td>
                    <span class="style50">
                    <label>
                    <input type="text" name="SETsigla" id="SETsigla">
                    </label>
                    *</span>        
                </td>
            </tr>
            <tr>
                <td class="texto">&nbsp;</td>
                <td>&nbsp; </td>
            </tr>
            <tr>
                <td class="texto style42">&nbsp;</td>
                <td>
                    <input name="Cadastrar" type="submit" id="Cadastrar" value="Confirmar" class="caixa_texto">&nbsp;&nbsp;&nbsp;
                    <input name="voltar" type="button" id="voltar" value="Voltar" class="caixa_texto" OnClick="location.href='formulario.php'"/>          
                </td>
            </tr>
		</table>
    </form>
</div>
</body>
</html>
<?php }?>